package org.test.file;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

import junit.framework.Assert;

import org.junit.Test;

import com.mchange.util.AssertException;

/**
 * 
 * @author game
 *
123456789
121111111111
2222222222222222222
33333333333333 *
 *
 */
public class FileOperation {

	/**
	 * 从指定地址拿回字符串
	 * @param filepath
	 */
	public StringBuffer readfile(String filepath) {

		File f = new File(filepath);
		StringBuffer sb = null;
		try {
			FileReader fr = new FileReader(f);
			BufferedReader bfr = new BufferedReader(fr);
			sb = new StringBuffer();
			for (String str = bfr.readLine(); str != null; str = bfr.readLine()) {
				sb.append(str);
			}
//			sb.append("\n");

		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return sb;

	}
	
	
	@Test
	public void testreadfile(){
		Assert.assertEquals("123456789121111111111222222222222222222233333333333333", (new FileOperation()).readfile("g:/s.txt").toString());
	}
}
